<style scoped>
  .layout-con {
    height: 100%;
    width: 100%;
  }

  .menu-item span {
    display: inline-block;
    overflow: hidden;
    width: 69px;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    transition: width .2s ease .2s;
  }

  .menu-item i {
    transform: translateX(0px);
    transition: font-size .2s ease, transform .2s ease;
    vertical-align: middle;
    font-size: 16px;
  }

  .collapsed-menu span {
    width: 0px;
    transition: width .2s ease;
  }

  .collapsed-menu i {
    transform: translateX(5px);
    transition: font-size .2s ease .2s, transform .2s ease .2s;
    vertical-align: middle;
    font-size: 22px;
  }

  .title-top-center {
    text-align: center;

  }

  .title-top-right {
    float: right
  }

  .btn_tools {
    padding: 6px 10px 6px 10px;
    background: #eee;
    border-radius: 20px;
  }

  .ivu-cell-extra {
    color: #ed4014;
  }
</style>
<template>
  <Row type="flex" justify="center" align="top" class="code-row-bg">
    <Col span="1" style="background:#3F88D5;height:100vh;">
      <NavLeft :selected="1" :avatar="avatar"></NavLeft>
    </Col>
    <Col span="4">
      <NavMiddle :itemList="itemList"></NavMiddle>
    </Col>
    <Col span="19" style="background:#f5f7f9;height:100vh;">
      <Layout>
        <Content :style="{padding: '0 16px 16px'}">
          <Breadcrumb :style="{margin: '16px 0'}">
            <Row type="flex" justify="space-between">
              <Col span="6">
                <a type="text" size="large" @click="$router.back(-1)">
                  <Icon type="ios-arrow-back"></Icon>
                  返回
                </a>

              </Col>
              <Col span="12" class="title-top-center"
                   style="font-size: 16px; font-weight: bold; color: rgb(70, 76, 91);text-align:center;">班组详情
              </Col>
              <Col span="6">

              </Col>
            </Row>

          </Breadcrumb>
          <Card :bordered="true" dis-hover>
            <div slot="title" style="">
              <Button shape="circle" :to="{path:'/item/parameter',query:{id:unit_id}}">主要参数</Button>
              <Button type="primary" shape="circle" style="margin-left:6px;"
                      :to="{path:'/item/rules',query:{id:unit_id}}">成绩规则
              </Button>
              <Button shape="circle" style="margin-left:6px;" :to="{path:'/item/push',query:{id:unit_id}}">推送等级</Button>
              <Button shape="circle" style="margin-left:6px;" :to="{path:'/item/manager',query:{id:unit_id}}">管理等级
              </Button>
              <Button shape="circle" style="margin-left:6px;" :to="{path:'/item/members',query:{id:unit_id}}">人员列表
              </Button>
              <Button shape="circle" style="margin-left:6px;" :to="{path:'/item/info',query:{id:unit_id}}">单元信息</Button>

            </div>

            <div>


              <CellGroup>
                <Cell title="成本" extra="成本达成率" to="/components/button"/>
                <Cell title="质量" extra="下线合格率" to="/components/button"/>
                <Cell title="设备" extra="异常停机时间" to="/components/button"/>
                <Cell title="士气" extra="出勤率" to="/components/button"/>
                <Cell title="5S" extra="安全事故、5S评分" to="/components/button"/>

              </CellGroup>

            </div>
          </Card>


        </Content>
      </Layout>
    </Col>
  </Row>
</template>
<script>
  import cookie from 'js-cookie';
  import NavLeft from '@/components/NavLeft';
  import NavMiddle from '@/components/NavMiddle';

  export default {
    data() {
      return {
        isCollapsed: false,
        itemList: [],
        itemInfo: [],
        tjList: [],
        chooseDate: cookie.get('chooseDate'),
        unit_id: "",
        avatar: ""
      };
    },
    components: {NavLeft: NavLeft, NavMiddle: NavMiddle},
    methods: {
      getData() {
        var uid = cookie.get('uid');
        var token = cookie.get('token');
        var unit_id = this.$route.query.id;
        if (!unit_id) {
          this.$Message.warning('无参数不能访问');
          return;
          //store.dispatch('setLoginStatus', 0)
          //window.location.reload()
        }
        this.$Loading.start();
        var str = {unit_id: unit_id, loginType: cookie.get('loginType'), ymd: this.chooseDate};
        var strdata = this.$twjsdes.enstr(str);
        this.$http.post(this.$API_URL + '/item/detail', {alldata: strdata.alldata}).then((response) => {
          this.$Loading.finish();
          var res = this.$twjsdes.decrypt(response.data.alldata);
          if (res.status == -1 && res.data.backurl) {
            this.$Modal.warning({
              title: '提示',
              content: '请在企业微信授权登录后使用',
              onOk: () => {
                window.location.href = res.data.backurl
              }
            });

          } else if (res.status != 1) {
            this.$Message.error(res.msg);
          } else {
            console.log(res.data);
            this.itemList = res.data.item_all_list;
            this.itemInfo = res.data;
            this.tjList = res.data.list;
            this.unit_id = res.data.unit_id;
            this.avatar = res.data.avatar;
          }
        }).catch(function (error) {
          this.$Modal.error({
            title: '提示',
            content: '网络连接错误，请检查后重试'
          });
          //console.log(error);
        });
      },
    },
    computed: {
      menuitemClasses: function () {
        return [
          'menu-item',
          this.isCollapsed ? 'collapsed-menu' : ''
        ]
      }
    },
    created() {
      window.document.title = 'SCS设置';
      this.getData();
    },
    mounted() {
    }
  }
</script>

